﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DARE
{
    public class CTimedItem
    {
        #region identifiers

        public delegate void TimedItemStartHandler();
        public delegate void TimedItemUpdateHandler(float startTime, float SequenceTime, float elapsedTime);

        #endregion

        #region fields

        #endregion

        #region properties

        public float Duration { get; set; }
        public float StartTime { get; private set; }

        public event TimedItemStartHandler StartEventHandler;
        public event TimedItemUpdateHandler UpdateEventHandler;
        public event TimedItemUpdateHandler FinishEventHandler;

        #endregion

        #region ctor


        #endregion

        #region methods

        public void Start(float sequenceTime)
        {
            StartTime = sequenceTime;
            if (StartEventHandler != null)
                StartEventHandler.Invoke();
        }

        public void Update(float startTime, float sequenceTime, float elapsedTime)
        {
            if (UpdateEventHandler != null)
                UpdateEventHandler.Invoke(startTime, sequenceTime, elapsedTime);
        }

        public void Finish(float startTime, float sequenceTime, float elapsedTime)
        {
            if (FinishEventHandler != null)
                FinishEventHandler.Invoke(startTime, sequenceTime, elapsedTime);
        }

        #endregion
    }
}
